package com.atguigu.petstore.shop.controller;

import com.atguigu.petstore.common.result.Result;
import com.atguigu.petstore.shop.entity.ShopCategory;
import com.atguigu.petstore.shop.service.ShopCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lfy
 * @Description
 * @create 2023-09-26 11:16
 */
@Tag(name = "商城分类维护")
@RequestMapping("/api/shop")
@RestController
public class ShopCategoryControlleer {

    @Autowired
    ShopCategoryService shopCategoryService;

    @Operation(summary = "获取商城分类树结构")
    @GetMapping("/category/tree")
    public Result getShopCategoryTree(){

        List<ShopCategory>  categories = shopCategoryService.getCategoryTree();


        return Result.ok(categories);
    }
}
